package main

import "fmt"

// range 遍历 slice map类型
func main() {
	ints := []int{1, 2, 3, 4}
	sum := 0
	for _, v := range ints {
		sum += v
	}
	fmt.Println(sum)

	for i, v := range ints {
		if v == 3 {
			fmt.Println("index is ", i)
		}
	}

	m := map[string]string{"a": "apple", "b": "banna"}
	for k, v := range m {
		fmt.Printf("%s -> %s \n", k, v)
	}

	for k := range m {
		fmt.Println("key is ", k)
	}

	for i, j := range "go" {
		fmt.Println(i, j)
	}
}
